/**
 * 
 */
package com.momosw.games.engine.simulator;

import java.util.Collection;

/**
 * <b>Project:</b> JerichoCardGame<br />
 * <b>Package:</b> com.momosw.games.engine.simulator<br />
 * <b>Class:</b> Normalizer.java<br />
 * <br />
 * <i>GSI 2011</i><br />
 *
 * @author Miguel Coronado (miguelcb84@gmail.com)
 * @version	Sep 7, 2011
 *
 */
public class Normalizer {

    private Collection<? extends Object> list;
    private int maxLength = 0;
    
    /**
     * 
     * @param list
     */
    public Normalizer (Collection<? extends Object> list) {
        this.list = list;
        
        for(Object obj : list){
            int strLen = obj.toString().length();
            if(strLen > maxLength){
                maxLength = strLen;
            }
        }
    }
    
    public String normalize (Object obj) {
        if(!list.contains(obj)){
            throw new IllegalArgumentException();
        }
        String str = obj.toString();
        for (int strLen = str.length(); strLen <= maxLength; strLen++ ){
            str += ' ';
        }
        return str;
    }
    
}
